from aip import AipSpeech
import recordFromMicrophone as recordTool
# """ 你的 APPID AK SK """
APP_ID = '31551394'
API_KEY = 'G2pMt5UzumhiPEGGjOCg2sY5'
SECRET_KEY = 'Kh0WSrKBQmaQlCkZI9ethzas3camerSG'
TEMP_AUDIO_PATH = './output.wav'


# 读取文件
def get_file_content(filePath):
    with open(filePath, 'rb') as fp:
        return fp.read()


client = AipSpeech(APP_ID, API_KEY, SECRET_KEY)
recordTool.createAudioFile()

# 识别本地文件
res = client.asr(get_file_content(TEMP_AUDIO_PATH), 'wav', 16000, {
    'dev_pid': 1536,
})
print(res)